package models;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.BelongsTo;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.annotations.Unique;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;



//替换部门
@Table(name="zjlist")
public class Zjlist extends ActiveRecordBase{
	@Id private Integer id;
	@Column 
	@Unique(message="单位编号不能重复")
	private String xh;
	@Column private String activated;
	@Column private Timestamp expiredate;
	@Column private String expirefailmsg;
	@Column private String jfqk;
	@Column private String mc;
	@Column private String sxname;
	@Column private String df1;
	@Column private String fax;
	@Column private String xm;
	@Column private String zw;
	@Column private String st;
	@Column private String bb;
	@Column private String xm1;
	@Column private String st1;
	@Column private String xm2;
	@Column private String st2;
	@Column private String xm3;
	@Column private String st3;
	@Column private String dz1;
	@Column private String yb1;
	@Column private String em1;
	@Column private String wz1;
	@Column private String qy;
	@Column private String bz;
	@Column private String lxr;
	@Column private String icp;
	@Column 
	@Unique(message="单位帐号不能重复")
	private String company_id;
	@Column private String usertype;
	@Column private String mainid;
	@Column private Integer showtop;
	@Column private Integer showweb;
	@Column private Integer topcount;
	@Column private Integer webcount;
	@Column private Timestamp indate;
	@Column private Timestamp outdate;


	//	@BelongsTo(foreignKey="demoId")
	//	private Demo demo;

	//	public Demo getDemo() {
	//		return demo;
	//	}
	//	public void setDemo(Demo demo) {
	//		this.demo = demo;
	//	}

	//	public int getChildCount() throws Exception {
	//		return (int)count(Zjlist.class, "parentId=?", new Object[]{id});
	//	}
	//	public String findChildIds() throws Exception {
	//		String s = "";
	//		List<Integer> ids = new ArrayList<Integer>();
	//		ids.add(id);
	//		while(!ids.isEmpty()){
	//			int id = ids.remove(0);
	//			s += id + ",";
	//			for(Zjlist item: Zjlist.findAll(Zjlist.class, "parentId=?", new Object[]{id})){
	//				ids.add(item.getId());
	//			}
	//		}
	//		if (!s.equals("")){
	//			s = s.substring(0, s.length() - 1);
	//		}
	//		return s;
	//	}
	public void setId(Integer id){
		this.id=id;
	}
	public Integer getId(){
		return id;
	}

	public void setXh(String xh){
		this.xh=xh;
	}
	public String getXh(){
		return xh;
	}

	public void setActivated(String activated){
		this.activated=activated;
	}
	public String getActivated(){
		return activated;
	}

	public void setExpiredate(Timestamp expiredate){
		this.expiredate=expiredate;
	}
	public Timestamp getExpiredate(){
		return expiredate;
	}

	public void setExpirefailmsg(String expirefailmsg){
		this.expirefailmsg=expirefailmsg;
	}
	public String getExpirefailmsg(){
		return expirefailmsg;
	}

	public void setJfqk(String jfqk){
		this.jfqk=jfqk;
	}
	public String getJfqk(){
		return jfqk;
	}

	public void setMc(String mc){
		this.mc=mc;
	}
	public String getMc(){
		return mc;
	}

	public void setSxname(String sxname){
		this.sxname=sxname;
	}
	public String getSxname(){
		return sxname;
	}

	public void setDf1(String df1){
		this.df1=df1;
	}
	public String getDf1(){
		return df1;
	}

	public void setFax(String fax){
		this.fax=fax;
	}
	public String getFax(){
		return fax;
	}

	public void setXm(String xm){
		this.xm=xm;
	}
	public String getXm(){
		return xm;
	}

	public void setZw(String zw){
		this.zw=zw;
	}
	public String getZw(){
		return zw;
	}

	public void setSt(String st){
		this.st=st;
	}
	public String getSt(){
		return st;
	}

	public void setBb(String bb){
		this.bb=bb;
	}
	public String getBb(){
		return bb;
	}

	public void setXm1(String xm1){
		this.xm1=xm1;
	}
	public String getXm1(){
		return xm1;
	}

	public void setSt1(String st1){
		this.st1=st1;
	}
	public String getSt1(){
		return st1;
	}

	public void setXm2(String xm2){
		this.xm2=xm2;
	}
	public String getXm2(){
		return xm2;
	}

	public void setSt2(String st2){
		this.st2=st2;
	}
	public String getSt2(){
		return st2;
	}

	public void setXm3(String xm3){
		this.xm3=xm3;
	}
	public String getXm3(){
		return xm3;
	}

	public void setSt3(String st3){
		this.st3=st3;
	}
	public String getSt3(){
		return st3;
	}

	public void setDz1(String dz1){
		this.dz1=dz1;
	}
	public String getDz1(){
		return dz1;
	}

	public void setYb1(String yb1){
		this.yb1=yb1;
	}
	public String getYb1(){
		return yb1;
	}

	public void setEm1(String em1){
		this.em1=em1;
	}
	public String getEm1(){
		return em1;
	}

	public void setWz1(String wz1){
		this.wz1=wz1;
	}
	public String getWz1(){
		return wz1;
	}

	public void setQy(String qy){
		this.qy=qy;
	}
	public String getQy(){
		return qy;
	}

	public void setBz(String bz){
		this.bz=bz;
	}
	public String getBz(){
		return bz;
	}

	public void setLxr(String lxr){
		this.lxr=lxr;
	}
	public String getLxr(){
		return lxr;
	}

	public void setIcp(String icp){
		this.icp=icp;
	}
	public String getIcp(){
		return icp;
	}

	public void setCompany_id(String company_id){
		this.company_id=company_id;
	}
	public String getCompany_id(){
		return company_id;
	}

	public void setUsertype(String usertype){
		this.usertype=usertype;
	}
	public String getUsertype(){
		return usertype;
	}

	public void setMainid(String mainid){
		this.mainid=mainid;
	}
	public String getMainid(){
		return mainid;
	}

	public void setShowtop(Integer showtop){
		this.showtop=showtop;
	}
	public Integer getShowtop(){
		return showtop;
	}

	public void setShowweb(Integer showweb){
		this.showweb=showweb;
	}
	public Integer getShowweb(){
		return showweb;
	}

	public void setTopcount(Integer topcount){
		this.topcount=topcount;
	}
	public Integer getTopcount(){
		return topcount;
	}

	public void setWebcount(Integer webcount){
		this.webcount=webcount;
	}
	public Integer getWebcount(){
		return webcount;
	}

	public void setIndate(Timestamp indate){
		this.indate=indate;
	}
	public Timestamp getIndate(){
		return indate;
	}

	public void setOutdate(Timestamp outdate){
		this.outdate=outdate;
	}
	public Timestamp getOutdate(){
		return outdate;
	}

	public int getChildCount() throws Exception {
		return (int) count(Zjlist.class, "mainid = '"+ company_id +"'", null);
	}

	public String findChildIds() throws Exception {
		String s = "";
		List<Zjlist> lists = Zjlist.findAll(Zjlist.class,
				" company_id = '"+ company_id +"' or mainid = '"+company_id+"'", null);
		
		for (Zjlist zjlist : lists) {
			s += zjlist.getId().toString() + ",";
		}
		
		if (!s.equals("")) {
			s = s.substring(0, s.length() - 1);
		}
		return s;
	}
}

